package com.cmict.data.infra.api.rdb;

import com.cmict.data.framework.common.pojo.CommonResult;
import com.cmict.data.framework.datapermission.core.annotation.DataPermission;
import com.cmict.data.infra.api.rdb.dto.SourceDTO;
import com.cmict.data.infra.controller.admin.rdb.vo.RdbSourceSql;
import com.cmict.data.infra.dal.dataobject.source.SourceDO;
import com.cmict.data.infra.service.rdb.RdbService;
import com.cmict.data.system.enums.ApiConstants;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController // 提供 RESTful API 接口，给 Feign 调用
@DubboService(version = ApiConstants.VERSION) // 提供 Dubbo RPC 接口，给 Dubbo Consumer 调用
@Validated
@DataPermission(enable = false) //忽略数据权限
public class RdbApiImpl implements RdbApi{

    @Resource
    private RdbService rdbService;

    @Override
    public CommonResult sourceTestList(Long id) {
        RdbSourceSql rdbSourceSql = new RdbSourceSql();
        rdbSourceSql.setId(id);
        return rdbService.sourceTestList(rdbSourceSql);
    }
    @Override
    public CommonResult<SourceDTO> getSourceDOById(Long id) {
        return CommonResult.success(rdbService.getSourceDOById(id));
    }
}
